home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 40
/
Aminet 40 (2000)(Schatztruhe)[!][Dec 2000].iso
/
Aminet
/
misc
/
emu
/
ATUtilities.lha
/
ATUtilities
/
M2
/
BADSIEV2.MOD
< prev
next >
Wrap
Text File
|
2000-09-26
|
869b
|
38 lines
MODULE sieve;
(* $L+ *)
FROM InOut IMPORT Read, Write, WriteString, WriteCard, WriteLn;
CONST
SIZE = 8190;
ITER = 10;
VAR
flag :ARRAY [0..SIZE] OF BOOLEAN;
i, j, k, count, prime :CARDINAL;
ch :CHAR;
BEGIN
WriteString("Hit a key to start 10 ITERATIONS");
Read(ch); WriteLn;
FOR i := 1 TO ITER DO
count := 0;
FOR j := 0 TO 10000 DO
flag[j] := TRUE;
END;
FOR j := 0 TO SIZE DO
IF flag[j] THEN
prime := j+j+3;
k := j+prime;
WHILE k <= SIZE DO
flag[k] := FALSE;
INC(k,prime);
END;
INC(count);
END;
END;
END;
Write(7C); WriteCard(count,4);
END sieve.